package com.xtt._01_java8.StreamAPI;

import org.junit.Test;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author xtt.
 * @Description:
 * @Date:Create in 2017/9/14 0014 下午 22:59
 * @Modify By:
 */
public class TestExample {
    /**
     * index.do?name=zhangsan&userId=123&token=1111
     */
    @Test
    public void test1() {
        String queryString = "name=zhangsan&userId=123&token=1111";
        Map<String, String> collect = Arrays.stream(queryString.split("&"))
                .map(x -> x.split("="))
                .collect(Collectors.toMap(x -> x[0], x -> x[1]));
        System.out.println(collect);
    }
}
